﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 实验四
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void btnDisplay_Click(object sender, EventArgs e)
        {
            Person ps = new Person();
            ps.Name = txtName.Text;
            ps.Sex = txtSex.Text;
            ps.Age = Convert.ToInt32(txtAge.Text);
            ps.Height = Convert.ToDouble(txtHeight.Text);
            ps.Weight = Convert.ToDouble(txtWeight.Text);
            lblShow.Text = ps.GetMessage();
        }
    }
    class Person
    {
        private string name;
        private string sex;
        private int age;
        private double height;
        private double weight;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public string Sex
        {
            get { return sex; }
            set { sex = value; }
        }
        public int  Age
        {
            get { return age; }
            set
            {
                if (value < 0) { value = 0; }
                age = value;
            }

        }
        public double Height
        {
            get { return height; }
            set { height = value; }
        }
        public double Weight
        {
            get { return weight; }
            set { weight = value; }
        }
        public string GetMessage()
        {
            return string.Format("基本信息如下：\n姓名：{0}\n性别：{1}\n年龄：{2}\n身高：{3}\n体重：{4}\n", name, sex, age, height, weight);
        }
    }
}
